package net.pokurt.aniryu.utils

import android.content.Context
import android.util.DisplayMetrics
import net.pokurt.aniryu.utils.constants.C

class Utils {
    companion object {

        fun getTypeName(typeValue: Int): String {

            return when (typeValue) {

                C.TYPE_RECENT_DUB -> "Recently Added (Dubbed)"
                C.TYPE_RECENT_SUB -> "Recently Added (Subbed)"
                C.TYPE_MOVIE -> "Movies"
                C.TYPE_POPULAR_ANIME -> "Popular"
                C.TYPE_GENRE -> "Categories"
                C.TYPE_NEW_SEASON -> "New Season"
                else -> "Default"
            }
        }

        fun calculateNoOfColumns(
            context: Context,
            columnWidthDp: Float
        ): Int {
            val displayMetrics: DisplayMetrics = context.resources.displayMetrics
            val screenWidthDp = displayMetrics.widthPixels / displayMetrics.density
            return (screenWidthDp / columnWidthDp + 0.5).toInt()
        }

        fun getPositionByType(typeValue: Int): Int {
            return when (typeValue) {
                C.TYPE_RECENT_SUB -> C.RECENT_SUB_POSITION
                C.TYPE_NEW_SEASON -> C.NEWEST_SEASON_POSITION
                C.TYPE_RECENT_DUB -> C.RECENT_SUB_POSITION
                C.TYPE_MOVIE -> C.MOVIE_POSITION
                C.TYPE_POPULAR_ANIME -> C.POPULAR_POSITION
                else -> 0
            }
        }
    }
}
